package uk.org.landeg.euler.problems;

import uk.org.landeg.euler.problems.framework.AbstractProblem;
import uk.org.landeg.euler.problems.framework.ProblemLauncher;

public class Problem028 extends AbstractProblem {
	public static void main(String[] args) {
		ProblemLauncher launcher = new ProblemLauncher(new Problem028());
		launcher.solve();
	}

	@Override
	public String getDescription() {
		return "What is the sum of the numbers on the diagonals in a 1001 by 1001 spiral formed in the same way?";
	}

	@Override
	public Integer getProblemNumber() {
		return 28;
	}

	@Override
	public Object solve() {
		notes.add("For each cycle of the spiral, of side length L, the total contributions is given by ");
		notes.add("4l^2 - 6l + 6");
		long total = 1;
		long thisTotal = 0;
		for (int l = 3 ; l<=1001 ; l++) {
			if (l%2!=0) {
				thisTotal = 4*l*l - 6*l +6;
				System.out.println(l + "\t" + thisTotal);
				total += thisTotal;
			}
		}
		return total;
	}
}
